﻿
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace SageKing.Database.SqlSugar.Entity.Contracts;

/// <summary>
/// SageKing消息结构表 基类
/// </summary>
public class SysSageKingMessageBase<T> : EntityTenantBaseData, IEntityVersionValidation
    where T : SysSageKingMessageAttributeBase
{

    [Required]
    [SugarColumn(ColumnDescription = "版本",DefaultValue ="0")]
    public virtual long Version { get; set; } = 0;

    /// <summary>
    /// 名称
    /// </summary>
    [Required, MaxLength(64)]
    [SugarColumn(ColumnDescription = "名称", Length = 64)]
    public virtual string Name { get; set; }


    /// <summary>
    /// 类型
    /// </summary>
    [Required]
    [SugarColumn(ColumnDescription = "类型")]
    public virtual int Type { get; set; }

    [SugarColumn(ColumnDescription = "描述")]
    public string? Description { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [SugarColumn(ColumnDescription = "状态")]
    public bool Status { get; set; } = false;


    [SugarColumn(IsIgnore = true)]
    [Newtonsoft.Json.JsonIgnore]
    [System.Text.Json.Serialization.JsonIgnore]
    public string Key
    {
        get
        {
            return $"{Name}_{Version}";
        }
    } 

    /// <summary>
    /// 属性集合
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(SysSageKingMessageAttributeBase.MessageId))]
    public List<T> Children { get; set; }
}
